//
//  DataSportsViewController.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/21.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "DataSportsViewController.h"

@interface DataSportsViewController ()

@property(nonatomic,strong) NSArray *titles;
@property(nonatomic,strong) NSArray *leaguePic;

@end

@implementation DataSportsViewController



- (void)viewDidLoad
{
    [super viewDidLoad];
    
    FuzzyPicture *fuzzyPicture = [[FuzzyPicture alloc] initWithImage:[UIImage imageNamed:@"bg_dg_match@2x"]];
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView setDelegate:self];
    [self.tableView setDataSource:self];
    [self.view addSubview:self.tableView];
    [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    
    self.tableView.backgroundView = fuzzyPicture;
    [self.view setBackgroundColor:[UIColor clearColor]];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
  
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    self.titles = @[@"中超",@"英超",@"西甲",@"意甲",@"德甲",@"法甲"];
    self.leaguePic = @[@"中超",@"英超",@"西甲",@"意甲",@"德甲",@"法甲"];
    [tableView registerClass:[DataSportsTableViewCell class] forCellReuseIdentifier:CellIdentifier];
    DataSportsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.leagueName.text = self.titles[indexPath.row];
    cell.leagueLogo.image = [UIImage imageNamed:self.leaguePic[indexPath.row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return kScreenIp6(107);
}

#pragma mark - headerView
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return kScreenIp6(50);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenIp6(100), kScreenIp6(30))];
//    headerView.backgroundColor = [UIColor grayColor];
//    UILabel *label = [[UILabel alloc] initWithFrame:headerView.frame];
//    label.text = @"联赛";
//    [headerView addSubview:label];
    return headerView;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *leagueTypes = @[kZhongchaoType,kYingchaoType,kXijiaType,kYijiaType,kDejiaType,kFajiaType];
    
    [self.mm_drawerController closeDrawerAnimated:YES completion:^(BOOL finished) {
        [DataViewController shareInstance].teamOrderUrl = [NSString stringWithFormat:@"%@%@%@",kFootballLeagueTeamOrderUrlPart1,leagueTypes[indexPath.row],kFootballLeagueTeamOrderUrlPart2];
        [DataViewController shareInstance].scoreOrderUrl = [NSString stringWithFormat:@"%@%@%@",kFootballLeagueScoreOrderUrlPart1,leagueTypes[indexPath.row],kFootballLeagueScoreOrderUrlPart2];
        [DataViewController shareInstance].assistOrderUrl = [NSString stringWithFormat:@"%@%@%@",kFootballLeagueAssistOrderUrlPart1,leagueTypes[indexPath.row],kFootballLeagueAssistOrderUrlPart2];
        [DataViewController shareInstance].leagueName = self.titles[indexPath.row];
        [[DataViewController shareInstance] requestData];
    }];
    
}

@end
